<template>
	<view class="list">
		<view style="text-align: center;margin: 30rpx 0;">
			<text style="font-size: 28rpx; color: gray;">请在电脑下载终端工具</text>
			<br />
			<text style="font-size: 24rpx; color: #55aaff;" @click="copy('https://mgp.xiaojusmart.com/mg.PrintTheProgram/publish.htm')">https://mgp.xiaojusmart.com/mg.PrintTheProgram/publish.htm</text>
		</view>
		<view class="list_item" v-for="(item,index) in list " :key="index">
			<view class="top">
				<image src="https://mg-print.oss-cn-shenzhen.aliyuncs.com/img/shop_img.png" mode=""></image>
				<text>{{item.DeviceName}}</text>
			</view>
			<view class="bottom">
				<view class="status">
					<text>设备状态：</text>
					<view :class="!item.IsState?'off_line':'on_line'">{{!item.IsState?'离线' :'在线'}}</view>
				</view>
				<!-- <view class="remove">
					移除
				</view> -->
			</view>
			<view class="bottom">
				<view class="status">
					<text>配置：</text>
					
					<view :class="!item.IsState?'off_line':'on_line'" v-for="(val,i) in splitStr(item.ConfigStr)" :key="i">{{val}}</view>
				</view>
				<!-- <view class="remove">
					移除
				</view> -->
			</view>
			<!-- <view class="bottom">
				<view class="status">
					<text>色彩：</text>
					<view :class="!item.IsState?'off_line':'on_line'">{{!item.IsState?'黑白' :'在线'}}</view>
				</view>
			</view> -->
		</view>
		<pageEmpty v-if="list.length==0" text="暂无设备"></pageEmpty>
	</view>
</template>

<script>
	import pageEmpty from '@/components/pageEmpty/pageEmpty'
	export default {
		components: {
			pageEmpty
		},
		data() {
			return {
				list: []
			};
		},
		methods: {
			async getList(id) {
				let res = await this.$api.post('MLogin/GetShopsDeiveState', {
					ShopID: id
				})
				console.log(res);
				this.list = res.data
			},
			copy(value) {
				let that = this
				uni.setClipboardData({
					data: value,
					success: function() {
						that.$pv.msg('已复制到剪切板')
					},
					fail: function() {
						that.$pv.msg('复制失败，请刷新重试')
					},
				});
			},
			splitStr(str){
				return str.split(",")
			}
		},
		onLoad(option) {
			console.log(option.ShopID);
			if (option.ShopID) {
				this.getList(option.ShopID)
			}
		}
	}
</script>
<style>
	page {
		background-color: #f6f6f6;
	}
</style>

<style lang="scss" scoped>
	.off_line {
		width: 72rpx;
		height: 40rpx;
		background: #F6F6F6;
		border-radius: 8rpx;
		font-size: 24rpx;
		color: #666666;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 20rpx;
	}

	.on_line {
		width: 72rpx;
		height: 40rpx;
		background: #E5F8F2;
		border-radius: 8rpx;
		font-size: 24rpx;
		color: #00BA82;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-left: 20rpx;
	}

	.remove {
		width: 96rpx;
		height: 48rpx;
		border-radius: 8rpx;
		border: 1rpx solid #FF4B4B;
		font-weight: 500;
		font-size: 24rpx;
		color: #FF4B4B;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.list_item {
		display: flex;
		flex-direction: column;
		padding: 24rpx;
		width: 702rpx;
		// height: 216rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-bottom: 20rpx;

		.top {
			box-sizing: content-box;
			padding-bottom: 30rpx;
			border-bottom: 1rpx solid #fafafa;
			display: flex;

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}

		.bottom {
			.status {
				display: flex;
				align-items: center;

			}

			display: flex;
			justify-content: space-between;
			align-items: center;
			flex: 1;
			margin-top: 20rpx;
		}
	}

	.list {
		display: flex;
		align-items: center;
		flex-direction: column;
		padding: 0 24rpx;
		margin-top: 30rpx;
	}
</style>